<%@page import="java.util.*" session="true"%>
<%@page import="Logica.BebeXml"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import = "Beans.Bebe"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>Proyecto Distribuido</title>
	<link href="css/style.css" rel="stylesheet" type="text/css"> 
	</head>
<% 
boolean visible = false;
boolean visible2 = true;
boolean visible3 = false;
String actionMethod=request.getMethod();
String url=request.getRequestURI().toString();
List<Bebe> lista = new ArrayList<Bebe>();
SimpleDateFormat sdf=new java.text.SimpleDateFormat("dd/MM/yyyy");
if(actionMethod.equalsIgnoreCase("post")){
    String nombre = request.getParameter("nombre");
    String apellido = request.getParameter("apellido");
    String cedula = request.getParameter("cedula");
    
    Bebe bebe = new Bebe();
    if(!nombre.equals("") || !apellido.equals("") || 
            !cedula.equals("")){
        bebe.setApellido(apellido);
        bebe.setNombre(nombre);
        bebe.setCedulaPapa(cedula);
        
    }else{
        bebe = null;
    }
    
        BebeXml xml = new BebeXml();
    lista = xml.ObtenerBebes(bebe);
    HttpSession sesion=request.getSession();
    sesion.setAttribute("lista", lista);
    if(lista.size() > 0)
        visible = true;
}

%>
	<body>
	<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
	<tbody><tr>
	<td>
	<table width="1000" border="0" cellspacing="0" cellpadding="0">
	<tbody><tr>
	<td background="images/top-bg.jpg"><div width="337" height="107"> <h1 style="font-size:40px"> Sistemas Distribuidos</h1> </div>
	  <table width="284" border="0" align="right" cellpadding="0" cellspacing="0">
	    <tbody>
	      
	      
	      </tbody></table>	  </td>
	</tr>
	</tbody></table>
	</td>
	</tr>
	
	<tr>
	<td id="button-bg">
	<ul>
	<li><a href="#" >Inicio</a></li>
	<li><a href="AgregarBebe.jsp">Agregar Bebe</a></li>
	<li><a href="AgregarConsulta.jsp">Agregar Consulta</a></li>
	<li><a href="GestionarBebe.jsp" class="highlight-button" >Gestionar Bebe</a></li>
	<li><a href="Respaldo.jsp" >Respaldo</a></li>
	</ul>
	</td>
	</tr>
	<tr>
	<td bgcolor="#ddeefe">
	<table width="1000" border="0" cellspacing="0" cellpadding="0">
	<tbody><tr>
	<td width="15" height="15"></td>
	<td></td>
	<td width="15" height="15"></td>
	<td width="263"></td>
	<td width="15" height="15"></td>
	</tr>
	<tr>
	<td>&nbsp;</td>
	<td colspan="3" align="center" valign="top">
	  <h1><img src="images/arrow.jpg" alt="" width="14" height="10" hspace="4" vspace="2"> Buscar Bebe </h1>
	  <form name="form1" method="post" action="">
	    <table width="523" border="0" >
	      <tr>
	        <td>Nombre:</td>
	        <td>
	          <label for="nombre"></label>
	          <input type="text" name="nombre" id="nombre" value="">
	          </td>
	        <td>Apellido:</td>
	        <td><label for="apellido"></label>
	          <input type="text" name="apellido" id="apellido" value=""></td>
	        </tr>
	      <tr>
	        <td>Cedula Representante:</td>
	        <td><label for="cedula"></label>
	          <input type="text" name="cedula" id="cedula" value=""></td>
	        <td>&nbsp;</td>
	        <td>&nbsp;</td>
	        </tr>
	      <tr>
	        <td colspan="4"><div align="center">
	          <input  type="submit" name="aceptar" id="aceptar" value="Buscar">
	          </div></td>
	        </tr>
	      </table>
	    </form>
	  <br>
   <table width="572" border="1" style="visibility:<% if(!visible ){ out.println("hidden"); }else out.println("visible"); %>" >
  <tr>
    <td width="172">Nombre:</td>
    <td width="152">Fecha de Nacimiento</td>
    <td width="161">Cedula del Representante</td>
    <td width="59">&nbsp;</td>
    <td width="59">&nbsp;</td>
  </tr>
  <% for(int i = 0; i < lista.size(); i++){ 
      String nombreCompleto = lista.get(i).getNombre() + " " + lista.get(i).getApellido();  %>
  <tr>
    <td><%= nombreCompleto %></td>
    <td><%= sdf.format(lista.get(i).getFechaNacimiento())  %></td>
    <td><%= lista.get(i).getCedulaPapa() %></td>
    <td><a href="EditarBebe.jsp?posicion=<%= i%>">Editar</a></td>
    <td><a href="ReporteConsulta.jsp?posicion=<%= i%>">Consultas</a></td>
  </tr>
  <% }%>
</table>

	  </br>
	  </td>
	<td>&nbsp;</td>
	</tr>
	</tbody></table>
	</td></tr>
	<tr>
	<td height="15" bgcolor="#DDEEFE"></td>
	</tr>
	<tr>
	<td class="footer-text"><a href="index.html">Home</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="#">About Us</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="#">Order</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="#">Affiliates</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="#">Newsletter</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="#">Contact Us</a><br>
	<span class="footer-text1">Copyright Â© 2009 domainforsale.com. All Rights Reserved</span></td>
	</tr>
	</tbody></table>
	
	
	
</body></html>